<template>
	<view class="BlockGoods" v-if="list.length">
		<view class="waterfall-container" style="width: 100%;height: 100%;">
			<view class="waterfall-item shop" v-for="(item,index) in list" :key='index' @click="goPage(item)">
				<image :src="item.item_picture" mode="widthFix"></image>
				<view class="waterfall-item-content">
					<view class="name fex2">{{item.item_title}}</view>
					<view class="seller_name" v-if="item.seller_name">
						<text class="iconfont icon-shop"></text>
						<text class="fex1">{{item.seller_name}}</text>
					</view>
					<view class="coupon" v-show="item.coupon_price>0">
						<text>券</text>
						<text class="solid">|</text>
						<text class="coupon-price">{{item.coupon_price}}</text>
					</view>
					<view class="prices">
						<view class="price">
							<text>{{item.item_final_price}}</text>
							<text>{{item.item_price}}</text>
						</view>
						<view class="go">买</view>
					</view>
					<view class="ret">
						<text class="rebate">返 | {{commissionAmount(item.commission_amount)}} sg</text>
						<!-- <text class="volume" v-if="item.item_volume>0">已售{{calculation(item.item_volume)}}</text> -->
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props:{
			list:{
				type:Array,
				default:()=>{
					return []
				},
				required:true,
				// 必填list列表
			},
			active:{
				type:Number,
				default:1
			}
		},
		data() {
			return {
				
			}
		},
		methods: {
			calculation(val){
				if(val>10000){
					val = Math.ceil(val/10000)+'万+'
					return val
				}
				return val
			},
			commissionAmount(val){
				val = Math.ceil(Number(val.replace(/,/g, ''))*20);
				return val;
			},
			goPage(item){
				if(item){
					item.custom_type = this.active;
					let itemStr = JSON.stringify(item)
					uni.setStorageSync("shop",itemStr)
					uni.navigateTo({
						url:'/pages/duomai/detail/detail?id='+item.item_id
					})
				}
			}
		}
	}
</script>

<style lang="less" scoped src="./BlockGoods.less">
</style>
